#ifndef CHATWINDOW_H
#define CHATWINDOW_H

#include <QMainWindow>
#include "logindialog.h"

class QUdpSocket;
namespace Ui {
class ChatWindow;
}

class ChatWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit ChatWindow(QWidget *parent = 0);
    ~ChatWindow();

private:
    Ui::ChatWindow *ui;
    QUdpSocket *receiver;
    QUdpSocket *senderAno;
    QSqlDatabase database;
    int port;

    int usr_id;
    QString usr_passwd;
    QString usr_name;
    QString usr_email;
    QByteArray chat;
    int usr_history;
    bool matchFlag;

    QString select_table = "select tbl_name name from sqlite_master where type = 'table'";
    QString create_sql = "create table user (chatid int primary key, passwd varchar(30), name varchar(30), email varchar(30), history int)";
    QString select_max_sql = "select max(chatid) from user";
    QString insert_sql = "insert into user values (?, ?, ?, ? ?)";
    //QString update_sql = "update user set name = :name where chatid = :chatid";
    QString select_sql = "select name from user";
    //QString select_all_sql = "select * from user";
    //QString delete_sql = "delete from user where chatid = ?";
    //QString clear_sql = "delete from user";

    QString select_nameInfo = "selcet * from user where name=";

private slots:
    void processPendingDatagram();

    void pushButton_clicked();
    void on_pushButton_3_clicked();
    void on_pushButton_8_clicked();
};

#endif // CHATWINDOW_H
